package com.xingongchang.baolebei.protocol;

import org.json.JSONException;
import org.json.JSONObject;
import com.external.activeandroid.Model;
import com.external.activeandroid.annotation.Column;
import com.external.activeandroid.annotation.Table;

@Table(name = "TOPIC_COMMENT")
public class TOPIC_COMMENT extends Model {

	@Column(name = "replyid")
	public int replyid;

	@Column(name = "userphoto")
	public String userphoto;
	
	@Column(name = "creaton")
	public String creaton;
	
	@Column(name = "userid", unique = true)
	public int userid;
	
	@Column(name = "sex")
	public int sex;

	@Column(name = "body")
	public String body;

	@Column(name = "username")
	public String username;
	
	@Column(name = "topicid")
	public int topicid;


	public static TOPIC_COMMENT fromJson(JSONObject jsonObject) throws JSONException {
		if (null == jsonObject) {
			return null;
		}
		TOPIC_COMMENT localItem = new TOPIC_COMMENT();

		localItem.userid = jsonObject.optInt("userid");
		localItem.replyid = jsonObject.optInt("id");
		localItem.sex = jsonObject.optInt("sex");
		localItem.body = jsonObject.optString("body");
		localItem.creaton = jsonObject.optString("creaton");

		localItem.userphoto = jsonObject.optString("userphoto");
		localItem.topicid = jsonObject.optInt("topicid");
		localItem.username = jsonObject.optString("username");

		return localItem;
	}

}